package com.buss.group.service.impl;
import com.buss.group.service.BnsGroupArticleServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import com.buss.group.entity.BnsGroupArticleEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
import java.io.Serializable;

@Service("bnsGroupArticleService")
@Transactional
public class BnsGroupArticleServiceImpl extends CommonServiceImpl implements BnsGroupArticleServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((BnsGroupArticleEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
 		this.doAddSql((BnsGroupArticleEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
 		this.doUpdateSql((BnsGroupArticleEntity)entity);
 	}
 	
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(BnsGroupArticleEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(BnsGroupArticleEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(BnsGroupArticleEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,BnsGroupArticleEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
 		sql  = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
 		sql  = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
 		sql  = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
 		sql  = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
 		sql  = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
 		sql  = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
 		sql  = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
 		sql  = sql.replace("#{title}",String.valueOf(t.getTitle()));
 		sql  = sql.replace("#{content}",String.valueOf(t.getContent()));
 		sql  = sql.replace("#{parent_id}",String.valueOf(t.getParentId()));
 		sql  = sql.replace("#{group_son_id}",String.valueOf(t.getGroupSonId()));
 		sql  = sql.replace("#{group_id}",String.valueOf(t.getGroupId()));
 		sql  = sql.replace("#{create_userid}",String.valueOf(t.getCreateUserid()));
 		sql  = sql.replace("#{create_time}",String.valueOf(t.getCreateTime()));
 		sql  = sql.replace("#{reply_account}",String.valueOf(t.getReplyAccount()));
 		sql  = sql.replace("#{view_account}",String.valueOf(t.getViewAccount()));
 		sql  = sql.replace("#{last_publish_userid}",String.valueOf(t.getLastPublishUserid()));
 		sql  = sql.replace("#{last_publish_time}",String.valueOf(t.getLastPublishTime()));
 		sql  = sql.replace("#{hot_num}",String.valueOf(t.getHotNum()));
 		sql  = sql.replace("#{is_recommend}",String.valueOf(t.getIsRecommend()));
 		sql  = sql.replace("#{is_new}",String.valueOf(t.getIsNew()));
 		sql  = sql.replace("#{is_up}",String.valueOf(t.getIsUp()));
 		sql  = sql.replace("#{is_close}",String.valueOf(t.getIsClose()));
 		sql  = sql.replace("#{is_zambia}",String.valueOf(t.getIsZambia()));
 		sql  = sql.replace("#{publisher_status}",String.valueOf(t.getPublisherStatus()));
 		sql  = sql.replace("#{support_account}",String.valueOf(t.getSupportAccount()));
 		sql  = sql.replace("#{oppose_account}",String.valueOf(t.getOpposeAccount()));
 		sql  = sql.replace("#{keep_account}",String.valueOf(t.getKeepAccount()));
 		sql  = sql.replace("#{share_account}",String.valueOf(t.getShareAccount()));
 		sql  = sql.replace("#{article_type}",String.valueOf(t.getArticleType()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}
}